package com.zyz.common.core.active;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;


@Slf4j
@Aspect
@Component
public class TimeAdvice {
    @SneakyThrows
    @Around("@annotation(com.zyz.common.core.active.Time)")
    public Object around(ProceedingJoinPoint joinPoint)  {
        long start = System.currentTimeMillis();
        Object proceed = joinPoint.proceed();
        long end = System.currentTimeMillis();
        log.info("方法: {} 耗时: {} ms", joinPoint.getSignature(),end - start );
        return proceed;
    }
}
